Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Jan 5, 2026

Objective

Add support for generic font families.

Solution

Support for generic font families has been added through new FontSource variants: Serif, SansSerif, Cursive, Fantasy, and Monospace.

The implementation is very simple, mostly just a mapping from the FontSource generic font family variants to the corresponding Cosmic Text Family variants.

The associated families can be changed using Cosmic Text's Database:

fn set_serif_font_family_system(mut font_system: ResMut<CosmicFontSystem>) {
    font_system.db_mut().set_serif_family("Times New Roman");
}

Showcase

Includes a very basic example, run with:

cargo run --example generic_font_families
Screenshot 2026-01-13 233807

…, creating a new font with a new font ID to cosmic text's FontDb from the font asset each text update.

This commit removes the responsibility of loading fonts to cosmic text's database and associating them with an asset id from `TextPipeline`. Instead the font family name is added to the `Font` asset after loading.

Then in `TextPipeline::update_buffer` it just gets the family name from the asset and there's no possibility of a leak.
@ickshonpe ickshonpe added S-Blocked This cannot move forward until something else changes A-Text Rendering and layout for characters D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact labels Jan 5, 2026
@ickshonpe ickshonpe added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Blocked This cannot move forward until something else changes labels Jan 13, 2026
@ickshonpe ickshonpe added the C-Feature A new feature, making something new possible label Jan 13, 2026
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These work via fallback to system defaults right? If so, that should be much clearer in the docs (variants, example, release notes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Text Rendering and layout for characters C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants